﻿Public Class FormBuscarRol

    Private _miCampeonato As Campeonato
    Private _resultadoBusqueda As List(Of String)
    Private _formDestino As String 'para enviar los datos a uno u otro formulario

    Property formDestino As String
        Get
            Return Me._formDestino
        End Get
        Set(value As String)
            Me._formDestino = value
        End Set
    End Property

    Private Sub FormBuscarRol_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = FormEntrada
        Me._miCampeonato = New Campeonato()
        Me._resultadoBusqueda = New List(Of String)
        Me.ListBox1.Items.Clear()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me._resultadoBusqueda = _miCampeonato.buscarRol()
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim TodosLosDatosSeparados = New String(14) {}
        Dim indiceElementoSelecionado As Integer = Me.ListBox1.SelectedIndex
        TodosLosDatosSeparados = CStr(_resultadoBusqueda(indiceElementoSelecionado)).Split(CChar("-"))

        If _formDestino = "FormAltaUsuario" Then
            FormAltaUsuario.tbxidRol.Text = TodosLosDatosSeparados(0)
            FormAltaUsuario.idRol = CInt(TodosLosDatosSeparados(1))
        End If
        Me.Close()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class